package service

import (
	"context"
	__ "goods-server/basic/proto"
	"goods-server/handler/model"
)

// server is used to implement helloworld.GreeterServer.
type Server struct {
	__.UnimplementedGoodsServer
}

// SayHello implements helloworld.GreeterServer
func (s *Server) LoginUser(_ context.Context, in *__.LoginUserReq) (*__.LoginUserResp, error) {
	var err error
	var u model.User
	u = model.User{
		Account:  in.Username,
		Password: in.Password,
	}

	err = u.LoginUser()
	if err != nil {
		return &__.LoginUserResp{
			Userid: int64(u.Id),
			Greet:  "登录失败",
		}, nil
	}

	return &__.LoginUserResp{
		Userid: int64(u.Id),
		Greet:  "登录成功",
	}, nil

}
